package com.anysoft.home;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.anysoft.HostConstant;
import com.anysoft.MentorConst;
import com.anysoft.R;
import com.anysoft.StaticField;
import com.anysoft.base.BaseActivity;
import com.anysoft.bean.AntiMoneyValidateBean;
import com.anysoft.bean.MobileWhiteBean;
import com.anysoft.bean.QueryFundInfoBean;
import com.anysoft.bean.QueryRiskLevelBean;
import com.anysoft.bean.QueryUserAssetsBean;
import com.anysoft.event.InterfaceCallback;
import com.anysoft.home.fragment.AccountTab;
import com.anysoft.home.fragment.FundNewAgainTab;
import com.anysoft.home.fragment.HomeTab;
import com.anysoft.home.fragment.WisdomWebviewTab;
import com.anysoft.utils.ActivityUtils;
import com.anysoft.utils.AnalyticsEventUtils;
import com.anysoft.utils.CommonUtil;
import com.anysoft.utils.HttpUtils;
import com.anysoft.utils.MentorLogger;
import com.anysoft.utils.NewVersionUtils;
import com.anysoft.utils.PreferencesUtils;
import com.anysoft.utils.StringUtils;
import com.anysoft.utils.user.UserBeanUtil;
import com.anysoft.view.dialog.IcbcDialog;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.orhanobut.logger.Logger;
import com.umeng.analytics.MobclickAgent;

import org.greenrobot.eventbus.EventBus;

import java.util.HashMap;
import java.util.Map;

import static com.anysoft.MentorApplication.context;

public class HomeActivity extends BaseActivity implements OnClickListener {
    private HomeTab homeTab;
    private AccountTab accountTab;
    private FundNewAgainTab fundTab;
    private WisdomWebviewTab wisdomWebviewTab;

    /**
     * 底部四个按钮
     */
    private LinearLayout mTabBtnHome;
    private LinearLayout mTabBtnZhihui;
    private LinearLayout mTabBtnFund;
    private LinearLayout mTabBtnZichan;

    private TextView tv_tab_bottom_home;
    private TextView tv_tab_bottom_zhihui;
    private TextView tv_tab_bottom_fund;
    private TextView tv_tab_bottom_zichan;
    /**
     * 用于对Fragment进行管理
     */
    private FragmentManager fragmentManager;

    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        if (PreferencesUtils.getBoolean(this, MentorConst.IS_FIRST_COME, true)) {
            PreferencesUtils.putBoolean(this, MentorConst.IS_FIRST_COME, false);
        }
        initViews();
        fragmentManager = getSupportFragmentManager();
        setTabSelection(0);
//        mobileWhiteGet();
//        checkVersion();
    }

    @Override
    protected void onResume() {
        super.onResume();
        EventBus.getDefault().post("HomeActivity-OnResume");
        if (!mentorApplication.needLogin()) {
            queryUserAssets();
            queryAntiMoneyValidate();
            queryRiskLevel();
        }
        if (XJKJDataBean == null) {
            queryFundInfo(HostConstant.XJKJ_CODE);
        }
        if (CJXJKJDataBean == null) {
            queryFundInfo(HostConstant.CJXJKJ_CODE);
        }
    }

    private void mobileWhiteGet() {
        OkGo.<String>post(HostConstant.MOBILE_WHITE_GET)
                .tag(this)
                .params(HttpUtils.getCommonParams(this, null))
                .execute(new com.lzy.okgo.callback.StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        updateMobileWhiteGet(response.body());
                    }


                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        showToast("网络加载失败，请稍后再试!");
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                    }
                });
    }

    /**
     * @param response
     */
    private void updateMobileWhiteGet(String response) {
        MobileWhiteBean bean;
        try {
            bean = new Gson().fromJson(response, MobileWhiteBean.class);
        } catch (Exception exception) {
            showConfirmAlert(this, "提示", "数据解析错误");
            return;
        }

        if (!CommonUtil.checkState(this, bean, response)) {
            return;
        }

        if (TextUtils.isEmpty(bean.getData())) {
            PreferencesUtils.putString(this, MentorConst.MOBILE_WHITE, "");
            return;
        }

        PreferencesUtils.putString(this, MentorConst.MOBILE_WHITE, bean.getData());
        MentorLogger.Loge(PreferencesUtils.putString(this, MentorConst.MOBILE_WHITE, bean.getData()) + "==" + bean.getData());
    }

    private void initViews() {

        mTabBtnHome = (LinearLayout) findViewById(R.id.id_tab_bottom_home);
        mTabBtnZhihui = (LinearLayout) findViewById(R.id.id_tab_bottom_zhihui);
        mTabBtnFund = (LinearLayout) findViewById(R.id.id_tab_bottom_fund);
        mTabBtnZichan = (LinearLayout) findViewById(R.id.id_tab_bottom_zichan);

        tv_tab_bottom_home = (TextView) findViewById(R.id.tv_tab_bottom_home);
        tv_tab_bottom_zhihui = (TextView) findViewById(R.id.tv_tab_bottom_zhihui);
        tv_tab_bottom_fund = (TextView) findViewById(R.id.tv_tab_bottom_fund);
        tv_tab_bottom_zichan = (TextView) findViewById(R.id.tv_tab_bottom_zichan);

        mTabBtnHome.setOnClickListener(this);
        mTabBtnZhihui.setOnClickListener(this);
        mTabBtnFund.setOnClickListener(this);
        mTabBtnZichan.setOnClickListener(this);
    }

    public int iUpSelectIndex = 0;
    public int iCurrSelectIndex = 0;

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.id_tab_bottom_home: //工银
                setTabSelection(0);
                break;
            case R.id.id_tab_bottom_zhihui: //智慧
                setTabSelection(1);
                break;
            case R.id.id_tab_bottom_fund: //基金
                setTabSelection(2);
                break;
            case R.id.id_tab_bottom_zichan: //资产
                setTabSelection(3);
                break;

            default:
                break;
        }
    }

    /**
     * 根据传入的index参数来设置选中的tab页。
     */
    @SuppressLint("NewApi")
    public void setTabSelection(int index) {
        if (index == 3 && mentorApplication.needLogin()) {
            iUpSelectIndex = iCurrSelectIndex;
            String userId = UserBeanUtil.getInstance().getLastLoginAndRecordUserId();
            ActivityUtils.gotoLogin(this, !StringUtils.isNullOrEmpty(userId), false, userId);
        }
        iCurrSelectIndex = index;
        // 重置按钮
        resetBtn();
        // 开启一个Fragment事务
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        // 先隐藏掉所有的Fragment，以防止有多个Fragment显示在界面上的情况
        hideFragments(transaction);
        switch (index) {
            case 0:
                // 当点击了消息tab时，改变控件的图片和文字颜色
                ((ImageView) mTabBtnHome.findViewById(R.id.btn_tab_bottom_home))
                        .setImageResource(R.mipmap.tb_home);
                tv_tab_bottom_home
                        .setTextColor(getResources().getColor(R.color.home_red_font));
                if (homeTab == null) {
                    // 如果MessageFragment为空，则创建一个并添加到界面上
                    homeTab = new HomeTab();
                    transaction.add(R.id.id_content, homeTab);
                } else {
                    // 如果MessageFragment不为空，则直接将它显示出来
                    transaction.show(homeTab);
                }
                break;
            case 1:
                // 当点击了动态tab时，改变控件的图片和文字颜色
                ((ImageView) mTabBtnZhihui.findViewById(R.id.btn_tab_bottom_zhihui))
                        .setImageResource(R.mipmap.tb_zhihui);
                tv_tab_bottom_zhihui
                        .setTextColor(getResources().getColor(R.color.home_red_font));

                if (wisdomWebviewTab == null) {
                    // 如果NewsFragment为空，则创建一个并添加到界面上
                    wisdomWebviewTab = new WisdomWebviewTab();
                    transaction.add(R.id.id_content, wisdomWebviewTab);
                } else {
                    // 如果NewsFragment不为空，则直接将它显示出来
                    transaction.show(wisdomWebviewTab);
                }
                if (homeTab.isSearchLayoutShow()) {
                    homeTab.hideSearchLayout();
                }
                break;
            case 2:
                // 当点击了消息tab时，改变控件的图片和文字颜色
                ((ImageView) mTabBtnFund.findViewById(R.id.btn_tab_bottom_fund))
                        .setImageResource(R.mipmap.tb_jijin);
                tv_tab_bottom_fund
                        .setTextColor(getResources().getColor(R.color.home_red_font));
                if (fundTab == null) {
                    // 如果MessageFragment为空，则创建一个并添加到界面上
                    fundTab = new FundNewAgainTab();
                    transaction.add(R.id.id_content, fundTab);
                } else {
                    // 如果MessageFragment不为空，则直接将它显示出来
                    transaction.show(fundTab);
                    fundTab.checkInit();
                }
                if (homeTab.isSearchLayoutShow()) {
                    homeTab.hideSearchLayout();
                }
                break;
            case 3:
                // 当点击了设置tab时，改变控件的图片和文字颜色
                ((ImageView) mTabBtnZichan.findViewById(R.id.btn_tab_bottom_zichan))
                        .setImageResource(R.mipmap.tb_zichan);
                tv_tab_bottom_zichan
                        .setTextColor(getResources().getColor(R.color.home_red_font));
                if (accountTab == null) {
                    // 如果SettingFragment为空，则创建一个并添加到界面上
                    accountTab = new AccountTab();
                    transaction.add(R.id.id_content, accountTab);
                } else {
                    // 如果SettingFragment不为空，则直接将它显示出来
                    transaction.show(accountTab);
                }
                if (homeTab.isSearchLayoutShow()) {
                    homeTab.hideSearchLayout();
                }
                break;
        }
        transaction.commit();
    }

    /**
     * 清除掉所有的选中状态。
     */
    private void resetBtn() {
        ((ImageView) mTabBtnHome.findViewById(R.id.btn_tab_bottom_home))
                .setImageResource(R.mipmap.tb_home_de);
        ((ImageView) mTabBtnZhihui.findViewById(R.id.btn_tab_bottom_zhihui))
                .setImageResource(R.mipmap.tb_zhihui_de);
        ((ImageView) mTabBtnFund.findViewById(R.id.btn_tab_bottom_fund))
                .setImageResource(R.mipmap.tb_jijin_de);
        ((ImageView) mTabBtnZichan.findViewById(R.id.btn_tab_bottom_zichan))
                .setImageResource(R.mipmap.tb_zichan_de);

        tv_tab_bottom_home.setTextColor(getResources().getColor(R.color.gray_01));
        tv_tab_bottom_zhihui.setTextColor(getResources().getColor(R.color.gray_01));
        tv_tab_bottom_fund.setTextColor(getResources().getColor(R.color.gray_01));
        tv_tab_bottom_zichan.setTextColor(getResources().getColor(R.color.gray_01));
    }

    /**
     * 将所有的Fragment都置为隐藏状态。
     *
     * @param transaction 用于对Fragment执行操作的事务
     */
    @SuppressLint("NewApi")
    private void hideFragments(FragmentTransaction transaction) {
        if (homeTab != null) {
            transaction.hide(homeTab);
        }
        if (fundTab != null) {
            transaction.hide(fundTab);
        }
        if (accountTab != null) {
            transaction.hide(accountTab);
        }
        if (wisdomWebviewTab != null) {
            transaction.hide(wisdomWebviewTab);
        }

    }

    @Override
    public void onBackPressed() {

        if (homeTab.isSearchLayoutShow()) {
            homeTab.hideSearchLayout();
            return;
        }

        IcbcDialog dialog = new IcbcDialog(mActivity);

        dialog.setAnimationEnable(true);
        dialog.setCancelable(false);
        dialog.setTitle("提示");
        dialog.setContentText("确定要退出XXXXXX吗？");
        dialog.setEditTextType(false);
        dialog.setNegativeListener("取消", new IcbcDialog.OnNegativeListener() {
            @Override
            public void onClick(IcbcDialog dialog) {
                dialog.dismiss();
            }
        });
        dialog.setPositiveListener("确认", new IcbcDialog.OnPositiveListener() {
            @Override
            public void onClick(IcbcDialog dialog) {
                dialog.dismiss();
                MobclickAgent.onKillProcess(HomeActivity.this);
                mentorApplication.signOut();
                AnalyticsEventUtils.toLogoutEvent(HomeActivity.this);
                android.os.Process.killProcess(android.os.Process.myPid());
                System.exit(0);
            }
        }).show();
    }

    private boolean isShowTotalAccount = true;

    /**
     * 获取总账户的状态
     *
     * @return
     */
    public boolean getShowTotalAccountStatus() {
        isShowTotalAccount = PreferencesUtils.getBoolean(this, String.format("%s$isShowTotalAccount", getFundCustomerNo()), true);
        return isShowTotalAccount;
    }

    public void isShowTotalAccount() {
        isShowTotalAccount = !isShowTotalAccount;
        PreferencesUtils.putBoolean(this, String.format("%s$isShowTotalAccount", getFundCustomerNo()),
                isShowTotalAccount);
        if (accountTab != null) {
            accountTab.setIsShowTotalAccount(isShowTotalAccount);
        }
        if (homeTab != null) {
            homeTab.setIsShowTotalAccount(isShowTotalAccount);
        }
    }

    public void checkVersion() {
        Map<String, String> params = new HashMap<>();
        params.put("plantform", "2");
        OkGo.<String>post(HostConstant.UPDATE)
                .tag(this)
                .params(HttpUtils.getCommonParams(this, params))
                .execute(new com.lzy.okgo.callback.StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        NewVersionUtils.checkVersion(mActivity, response.body(), false);
                    }


                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        showToast("网络加载失败，请稍后再试!");
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                    }
                });
    }

    private Map<String, Boolean> mapDataQuery;//记录接口是否正在获取中

    /**
     * 获取接口当前状态  ture：正在获取 false 获取完成
     *
     * @param key
     * @return
     */
    private boolean getDataQueryState(String key) {
        if (mapDataQuery == null || StringUtils.isNullOrEmpty(key)) {
            return false;
        }
        if (mapDataQuery.containsKey(key)) {
            Boolean bool = mapDataQuery.get(key);
            return bool == null ? false : bool;
        }
        return false;
    }

    /**
     * 设置接口当前状态   ture：正在获取 false 获取完成
     *
     * @param key
     * @param bool
     */
    private void setDataQueryState(String key, boolean bool) {
        if (StringUtils.isNullOrEmpty(key)) {
            return;
        }
        if (mapDataQuery == null) {
            mapDataQuery = new HashMap<String, Boolean>();
        }
        mapDataQuery.put(key, bool);
    }

    /**
     * 查询基金详情
     */
    public void queryFundInfo(final String fundCode) {
        if (StringUtils.isNullOrEmpty(fundCode)) {
            return;
        }
        if (getDataQueryState(HostConstant.QUERY_FUND_INFO + fundCode)) {
            return;
        }
        setDataQueryState(HostConstant.QUERY_FUND_INFO + fundCode, true);
        Map<String, String> params = new HashMap<>();
        params.put("fundCode", fundCode);
        OkGo.<String>post(HostConstant.QUERY_FUND_INFO)
                .tag(this)
                .params(HttpUtils.getCommonParams(this, params))
                .execute(new com.lzy.okgo.callback.StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        setDataQueryState(HostConstant.QUERY_FUND_INFO + fundCode, false);
                        parseJson_fund(response.body());
                    }


                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        setDataQueryState(HostConstant.QUERY_FUND_INFO + fundCode, false);
                        showToast("网络加载失败，请稍后再试!");
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                    }
                });
    }

    /**
     * 23.	用户风险等级查询
     */
    public void queryRiskLevel() {

        Map<String, String> params = new HashMap<>();
        params.put("token", mentorApplication.userBean.getToken());
        params.put("fundCustomerNo", mentorApplication.userBean.getFundCustomerNo());
        OkGo.<String>post(HostConstant.QUERY_RISK_LEVEL)
                .tag(this)
                .params(HttpUtils.getCommonParams(this, params))
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        parseJson_level(response.body());
                    }


                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        showToast("网络加载失败，请稍后再试!");
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                    }
                });
    }

    /**
     * 资产查询
     */
    public void queryUserAssets() {
        Map<String, String> params = new HashMap<>();
        params.put("token", mentorApplication.userBean.getToken());//
        params.put("fundCustomerNo", mentorApplication.userBean.getFundCustomerNo());//
        OkGo.<String>
                post(HostConstant.QUERY_USER_ASSETS)
                .tag(this)
                .params(HttpUtils.getCommonParams(this, params))
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        parseJson(response.body());
                    }


                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        EventBus.getDefault().post(new InterfaceCallback(InterfaceCallback.ERROR, HostConstant.QUERY_USER_ASSETS));
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                    }
                });
    }

    /**
     * 解析从查询基金详情接口返回的数据
     *
     * @param json
     */
    private void parseJson_fund(String json) {
        QueryFundInfoBean bean;
        try {
            bean = new Gson().fromJson(json, QueryFundInfoBean.class);
        } catch (Exception exception) {
            showConfirmAlert(this, "提示", "数据解析错误");
            return;
        }

        if (!CommonUtil.checkState(this, bean, json)) {
            return;
        }

        if (bean == null || bean.getData() == null) {
            this.showConfirmAlert(this, "提示", getString(R.string.no_data));
            return;
        }
        if (HostConstant.XJKJ_CODE.equals(bean.getData().getFundcode())) {
            XJKJDataBean = bean;
            EventBus.getDefault().post(new InterfaceCallback(InterfaceCallback.SUCCESS, HostConstant.QUERY_FUND_INFO + "_" + HostConstant.XJKJ_CODE));
        } else if (HostConstant.CJXJKJ_CODE.equals(bean.getData().getFundcode())) {
            CJXJKJDataBean = bean;
            EventBus.getDefault().post(new InterfaceCallback(InterfaceCallback.SUCCESS, HostConstant.QUERY_FUND_INFO + "_" + HostConstant.CJXJKJ_CODE));
        }

    }

    /**
     * 解析返回的 用户风险等级json
     *
     * @param response
     */
    private void parseJson_level(String response) {
        QueryRiskLevelBean bean;

        try {
            bean = new Gson().fromJson(response, QueryRiskLevelBean.class);
        } catch (Exception e) {
            Logger.e(TAG, "Gson解析数据时发生异常");
            e.printStackTrace();
            return;
        }

        if (!CommonUtil.checkState(this, bean, response)) {
            return;
        }
        setUserLevel(bean.getData().getLevel());
        setQueryRiskLevelBean(bean);
        EventBus.getDefault().post(new InterfaceCallback(InterfaceCallback.SUCCESS, HostConstant.QUERY_RISK_LEVEL));
    }

    private void parseJson(String json) {
        QueryUserAssetsBean bean;
        try {
            bean = new Gson().fromJson(json, QueryUserAssetsBean.class);
        } catch (Exception exception) {
            showConfirmAlert(this, "提示", "数据解析错误");
            return;
        }

        if (!CommonUtil.checkState(this, bean, json)) {
            return;
        }

        if (bean == null || bean.getData() == null) {
            this.showConfirmAlert(this, "提示", getString(R.string.no_data));
            return;
        }
        setQueryUserAssetsBean(bean);
        EventBus.getDefault().post(new InterfaceCallback(InterfaceCallback.SUCCESS, HostConstant.QUERY_USER_ASSETS));
//        EventBus.getDefault().post(new InterfaceCallback(bean));
    }

    private QueryRiskLevelBean queryRiskLevelBean;
    private QueryUserAssetsBean queryUserAssetsBean;

    /**
     * 用来 记录现金快线和超级现金快线基金详情实体对象
     */
    private QueryFundInfoBean XJKJDataBean;
    private QueryFundInfoBean CJXJKJDataBean;

    public QueryRiskLevelBean getQueryRiskLevelBean() {
        return queryRiskLevelBean;
    }

    public void setQueryRiskLevelBean(QueryRiskLevelBean queryRiskLevelBean) {
        this.queryRiskLevelBean = queryRiskLevelBean;
    }

    public QueryUserAssetsBean getQueryUserAssetsBean() {
        return queryUserAssetsBean;
    }

    public void setQueryUserAssetsBean(QueryUserAssetsBean queryUserAssetsBean) {
        this.queryUserAssetsBean = queryUserAssetsBean;
    }

    public QueryFundInfoBean getXJKJDataBean() {
        return XJKJDataBean;
    }

    public void setXJKJDataBean(QueryFundInfoBean XJKJDataBean) {
        this.XJKJDataBean = XJKJDataBean;
    }

    public QueryFundInfoBean getCJXJKJDataBean() {
        return CJXJKJDataBean;
    }

    public void setCJXJKJDataBean(QueryFundInfoBean CJXJKJDataBean) {
        this.CJXJKJDataBean = CJXJKJDataBean;
    }

    /**
     * 获取反洗钱信息
     */
    public void queryAntiMoneyValidate() {
        Map<String, String> params = new HashMap<>();
        params.put("version", StaticField.getVersionName(context));
        params.put("clientType", "xjkxApp");
        params.put("customerNo", getFundCustomerNo());
        OkGo.<String>post(HostConstant.ANTIMONEY_VALIDATE)
                .tag(this)
                .upJson(new Gson().toJson(params))
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        parseJson_antiMoneyValidate(response.body());
                    }


                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                    }
                });
    }

    private void parseJson_antiMoneyValidate(String response) {
        AntiMoneyValidateBean bean;
        try {
            bean = new Gson().fromJson(response, AntiMoneyValidateBean.class);
        } catch (Exception exception) {
            showConfirmAlert(this, "提示", "数据解析错误");
            return;
        }

        setAntiMoneyValidateBean(bean);
        EventBus.getDefault().post(new InterfaceCallback(InterfaceCallback.SUCCESS, HostConstant.ANTIMONEY_VALIDATE));
    }

    private AntiMoneyValidateBean antiMoneyValidateBean;

    public AntiMoneyValidateBean getAntiMoneyValidateBean() {
        return antiMoneyValidateBean;
    }

    public void setAntiMoneyValidateBean(AntiMoneyValidateBean antiMoneyValidateBean) {
        this.antiMoneyValidateBean = antiMoneyValidateBean;
    }

    public void showTotalIncomAlert(String content) {
        IcbcDialog showConfirmAlertDialog = new IcbcDialog(this);
        showConfirmAlertDialog = new IcbcDialog(this);
        showConfirmAlertDialog.setCancelable(false);
        showConfirmAlertDialog.setAnimationEnable(true);
//        showConfirmAlertDialog.setContentTextGravity(Gravity.START);
        showConfirmAlertDialog.setTitle("提示");
        showConfirmAlertDialog.setmPositiveBackgroundResId(R.drawable.sel_def_gray_pos);
        showConfirmAlertDialog.setContentText(content);
        showConfirmAlertDialog.setPositiveListener("确定", new IcbcDialog.OnPositiveListener() {
            @Override
            public void onClick(IcbcDialog dialog) {
                dialog.dismiss();
            }
        }).show();
    }

}
